import React from "react";
import dayjs from "dayjs";
import { Space, Button } from "antd";
import { authButton } from "@/common";


/**@description 列表表格字段 */
const getColumns = ({ open = Function, handleDelete = Function }) => {
    const columns = [
        {
            title: "发布时间",
            key: "createDate",
            dataIndex: "createDate",
            width: 180,
            render: (text) => dayjs(text).format("YYYY-MM-DD HH:mm")
        },
        {
            title: "标题",
            key: "title",
            dataIndex: "title",
            width: 180,
        },
        {
            title: "简介",
            key: "recommend",
            dataIndex: "recommend",
        },
        {
            title: "操作",
            key: "action",
            dataIndex: "action",
            width: 180,
            render: (text, record) => {
                return <Space>
                    {
                        authButton("context:subject:list:update") && <Button type="link" onClick={() => open({ type: "update", record: record })}>修改</Button>
                    }
                    {
                        authButton("context:subject:list:delete") &&  <Button type="link" danger onClick={() => handleDelete(record)}>删除</Button>
                    }

                   
                </Space>
            }
        }
    ];
    return columns;
}

export default getColumns;